/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: javase2203 - T11
 * <p>Powered by webrx On 2022-08-09 14:19:41
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class T11 {
    volatile boolean f = true;
    void work(){
        String t = Thread.currentThread().getName();
        System.out.println(t+"启动");
        while(f){

        }
        System.out.println(t+"结束");
    }
    public static void main(String[] args) {
        T11 t = new T11();
        Thread tt = new Thread(t::work);
        tt.setName("tt1");
        tt.setPriority(Thread.MAX_PRIORITY);
        tt.start();

        try{
            TimeUnit.SECONDS.sleep(5);
            t.f = false;
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
